﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StoreTransport.DTO {
    public class ProductOrderDTO {
        public int ProductKindID{ get; set; }
        public string ProductKindName { get; set; }
        public int SumInventoryNumber { get; set; }
        public double SumSaleRate { get; set; }
        public int SumComputedNumber { get; set; }
        public int numberWarningDay { get; set; }
        public DateTime WarningDate { get; set; }
        public int OrderDays { get; set; }
        public int NumberStoreDays { get; set; }
        public int NumberRecieveProduct { get; set; }
        public int OrderQuantity {
            get {
                if (WarningDate <= DateTime.Today) {
                    var numberOrderDay = Convert.ToInt32(((SumComputedNumber + NumberRecieveProduct) / (double)SumSaleRate) + 0.5);
                    numberOrderDay = numberOrderDay - NumberStoreDays;
                    if (numberOrderDay >= 0) {
                        return Convert.ToInt32(SumSaleRate * OrderDays);
                    } else {
                        return Convert.ToInt32(SumSaleRate * (OrderDays + (-numberOrderDay)));
                    }
                } else {
                    return 0;
                }
            }
        }
    }
}
